package com.tedu.day05mybatis.mapper;

import com.tedu.day05mybatis.pojo.Comment;
import com.tedu.day05mybatis.pojo.CommentVO1;
import com.tedu.day05mybatis.pojo.CommentVO2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Insert("INSERT INTO comment(content,created,user_id,weibo_id) VALUES (#{content},#{created},#{userid},#{weiboid})")
    int InsettComment(Comment comment);

    @Delete("DELETE FROM comment WHERE id=#{id}")
    int DeleteCommentByid(Integer id);

    @Update("UPDATE comment SET content=#{content},created=#{created},user_id=#{userid},weibo_id=#{weiboid}")
    int updateComment(Comment comment);

    @Select("SELECT content,user_id userid FROM comment WHERE id=#{id}")
    CommentVO1 selectCommentById(Integer id);

//    @Select("SELECT id,content,user_id userid FROM comment WHERE id=#{id}")
//    CommentVO2 selectCommentById2(Integer id);

    @Select("SELECT id,content,user_id userid FROM comment WHERE user_id=#{userid}")
    List<CommentVO2> selectCommentByUserId(Integer userId);
}
